package com.moduls.interfaceFunction.controller;

import com.moduls.interfaceFunction.core.Result;
import com.moduls.interfaceFunction.core.ResultGenerator;
import com.moduls.interfaceFunction.core.SqlMapper;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("db")
public class DBController {

    @Autowired
    private SqlSession sqlSession;
    /*@GetMapping("/getlist")
    public Result getList(@RequestParam String sql) {
        SqlMapper sqlMapper=new SqlMapper(sqlSession);
        List<Map<String, Object>> list=  sqlMapper.selectList(sql);
        return ResultGenerator.genSuccessResult(list);
    }*/
    
    @RequestMapping("/test")
    public Result getOne() throws SQLException{
    	 SqlMapper sqlMapper=new SqlMapper(sqlSession);
    	 Map<String, String> map =new HashMap<>();
    	 map.put("industryname", "搬运搬家");
    	 map.put("industrypid", "2");
    	 int res=sqlMapper.insert_or_update("wx_industry",map,null);
         return ResultGenerator.genSuccessResult(res);
    }
    
    
}
